<?xml version="1.0" encoding="utf-8" ?>
<!-- #INCLUDE FILE="inc/initDb.inc" -->
<!-- #INCLUDE FILE="inc/Common.asp" -->
<!-- #INCLUDE FILE="inc/RSSCommon.asp" -->
<%
    Response.Clear
    Response.ContentType = "text/xml"

    title = "Job Search Result"
    Dim tabSelected
    tabSelected = "candidates"

    Dim Branches(5)
    Branches(0) = "Banking"
    Branches(1) = "Engineering"
    Branches(2) = "Events/Exhibitions"
    Branches(3) = "Information Technology"
    Branches(4) = "Japanese"
    Branches(5) = "Tampines 2/Technical East"

	Dim SearchCriteria
    Function isValidBranch(str)
        For i = 0 to UBound(Branches)
            If ucase(str) = ucase(Branches(i)) Then
            	SearchCriteria = Branches(i) & " Jobs"
                isValidBranch =  True
                Exit Function
            End If
        Next

        isValidBranch = False

    End Function

    Dim page_no, SortOrder, Branch
    '------------------------------------------------------------------------------------------------------------------------
    'Init Parameters from the form ------------------------------------------------------------------------------------------
    '------------------------------------------------------------------------------------------------------------------------
    page_no = 1
    SortOrder = ""
    Branch = Request.QueryString("Branch")

    If Branch = "" or not isValidBranch(Branch) Then
        Response.Redirect("Candidates_search.asp")
    ElseIf Branch = "Japanese" Then
        Response.Redirect("http://www.adecco-asia.com/Japanese/")
    End If

    '------------------------------------------------------------------------------------------------------------------------
    'Create the SQL Statements ----------------------------------------------------------------------------------------------
    '------------------------------------------------------------------------------------------------------------------------
    Set cmd = Server.CreateObject("ADODB.Command") 'init the cmd here, because we may need to declare params later on

    sql = "SELECT * FROM JOB_ADVERTISEMENT WHERE 1=1 AND BRANCH <> 'JP' "

    sql = sql & " AND CURRENT_TIMESTAMP >= POSTING_DATE"
    sql = sql & " AND CLOSING_DATE >= POSTING_DATE"
    sql = sql & " AND CLOSING_DATE >= CURRENT_TIMESTAMP"
    sql = sql & " AND BRANCH_NAME = ?"

    set sqlParam = cmd.CreateParameter(, 200, , 40, Branch)
    cmd.Parameters.Append sqlParam

    sql = sql & " ORDER BY POSTING_DATE DESC"
    '------------------------------------------------------------------------------------------------------------------------
    'Executing the SQL Statements using params (?) to prevent SQL Injection -------------------------------------------------
    '------------------------------------------------------------------------------------------------------------------------
    SqlConn.Open
    cmd.ActiveConnection = SqlConn
    cmd.CommandText = sql

    Set rs = Server.CreateObject("ADODB.RecordSet")
    rs.Open cmd, , 3
%>
<rss version="2.0">
  <channel>
    <title>
      Adecco Job Search Results (RSS) for: <%=SearchCriteria %>
    </title>
    <link>http://www.adecco.com.sg</link>
    <description>
        Adecco Job Search Results for: <%=SearchCriteria %>
    </description>
    <language>en</language>
    <copyright>2009 Adecco. All Rights Reserved</copyright>
    <image>
      <title>Adecco Singapore Job Search Result RSS Feed</title>
      <url>http://www.adecco-asia.com/Singapore/asset/images/adeccoLogo.png</url>
      <link>http://www.adecco.com.sg</link>
    </image>

    <%
        If rs.RecordCount = 0 Then
    %>
            <item>
                <title>No Jobs Found</title>
                <link>http://www.adecco-asia.com/singapore/candidates_search.asp</link>
                <description>Click <%=Server.HTMLEncode("<a href='http://www.adecco-asia.com/singapore/candidates_search.asp'>here</a>") %> to find for more jobs</description>
            </item>
    <%
        End If
    %>


    <%
        Do While NOT rs.BOF and NOT rs.EOF
    %>
            <item>
                <title><%=server.HTMLEncode(rs("JOB_ADV_TITLE") & " (" & rs("SERVICE_TYPE") & ")")%></title>
                <link>Candidates_JobDetails.asp?jobID=<%=server.HTMLEncode(rs("JOB_ADV_CODE")) %></link>
                <description><%=server.HTMLEncode(cSubString(rs("JOB_ADV_DESC"), rs("JOB_ADV_CODE")))%></description>
                <category><%=server.HTMLEncode(rs("SERVICE_TYPE")) %></category>
                <pubDate><%=return_RFC822_Date(rs("POSTING_DATE"), "GMT")%></pubDate>
            </item>
    <%
            rs.movenext
        Loop
    %>
  </channel>
</rss>